package com.ruoyi.project.wf.provider;

import cn.hutool.core.convert.Convert;
import com.ruoyi.project.system.domain.SysPost;
import com.ruoyi.project.system.service.ISysPostService;
import com.ruoyi.project.system.service.ISysUserService;
import com.ruoyi.project.wf.api.WfUserApi;
import com.ruoyi.project.wf.enums.FlowConst;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 工作流用户担任者
 * @author mldong
 * @date 2023/10/7
 */
@Component
@RequiredArgsConstructor
public class WfUserProvider implements WfUserApi {
    private final ISysUserService sysUserService;
    private final ISysPostService sysPostService;
    @Override
    public String getRealName(String userName) {
        return sysUserService.selectUserByUserName(userName).getNickName();
    }

    @Override
    public String getDeptId(String userName) {
        return sysUserService.selectUserByUserName(userName).getDeptId()+"";
    }

    @Override
    public String getDeptName(String userName) {
        return sysUserService.selectUserByUserName(userName).getDept().getDeptName();
    }

    @Override
    public String getPostId(String userName) {
        List<Long> longs = sysPostService.selectPostListByUserName(userName);
        return longs.get(0)+"";
    }

    @Override
    public String getPostName(String userName) {
        List<Long> longs = sysPostService.selectPostListByUserName(userName);
        SysPost sysPost = sysPostService.selectPostById(longs.get(0));
        return sysPost.getPostName();
    }
}
